<?php

namespace app\data\controller\api\auth;

use app\data\controller\api\Auth;

class MonitoringStation extends Auth
{
    /**
     * 服务商检测站列表
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function get()
    {
        $carMonitoringStations = $this->app->db->name('CarMonitoringStationRelation')
            ->where('uuid', $this->uuid)->select()->toArray();
        $carMonitoringStationIds = array_column($carMonitoringStations, 'car_monitoring_station_id');
        $result = $this->app->db->name('CarMonitoringStation')->field('id,name')
            ->whereIn('id', $carMonitoringStationIds)
            ->where('deleted', 0)
            ->where('status', 1)
            ->order('id desc')->select();
        $this->success('获取检测站数据！', $result);
    }

}